//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_getranpointcirclebigouter.sqf"
#include "x_setup.sqf"

// get a random point inside a circle for bigger objects
// parameters:
// center position, radius of the circle
// example: _random_point = [position trigger1, 200] call FUNC(GetRanPointCircleBigOuter);
private ["_center", "_radius", "_co", "_center_x", "_center_y","_x","_y","_rng"];
PARAMS_2(_center,_radius);
_rng = 200;
if (count _this > 2) then { _rng = _this select 2; };
_center_x = _center select 0;_center_y = _center select 1;
_ret_val = [];
for "_co" from 0 to 99 do {
	_x = random(_rng * 2) - _rng;
	_y = random(_rng * 2) - _rng;
	_x = if (_x > 0) then { _center_x + _radius + _x + 100 } else { _center_x - _radius - _x - 100 };
	_y = if (_y > 0) then { _center_y + _radius + _y + 100 } else { _center_y - _radius - _y - 100 };
	_posee = [_x, _y, 0];
	_isFlat = _posee isFlatEmpty [
		10,	//--- Minimal distance from another object
		0,				//--- If 0, just check position. If >0, select new one
		0.7,				//--- Max gradient
		13,	//--- Gradient area
		0,				//--- 0 for restricted water, 2 for required water,
		false,				//--- True if some water can be in 25m radius
		objNull			//--- Ignored object
	];
	// TYRGHEN - Added check for terrain under water level
	if (count _isFlat > 0 && {!isOnRoad _isFlat} && {(_isFlat select 2) >= 0}) exitWith {
		//"mmm" setMarkerPos _isFlat;
		_ret_val = ASLToATL _isFlat;
	};
};
__TRACE_1("","_ret_val")
_ret_val